package com.lucas.boot;

import com.lucas.pojo.RpcConsumer;
import com.lucas.service.UserService;
import com.lucsa.pojo.RpcRequest;

import java.util.Random;


public class BootStrap {
    private static RpcRequest providerRpcRequest= new RpcRequest();

    //旧版本(案例版本)
//    private static String provider = "userService#sayHello";



//    private static String provider;

    public static void main(String[] args) throws InterruptedException {

        RpcConsumer rpcConsumer = new RpcConsumer();
        providerRpcRequest.setClassName("com.lucas.Service.UserServiceImpl");
        providerRpcRequest.setMethodName("sayHello");
        providerRpcRequest.setParameterTypes(new Class[]{Object.class});
        providerRpcRequest.setParameters(new Object[]{"1"});
        providerRpcRequest.setRequestId(new Random().toString());
        UserService o = (UserService)rpcConsumer.creatProxy(UserService.class);

        for(;;){
            System.out.println("====客户端开始准备发送消息=====");
            String s = o.sayHello(providerRpcRequest);
            System.out.println(s);
            Thread.sleep(2000);
        }
    }
}
